package com.cheng.example.atguigu.view2;

/**
 * 多线程单例出现的问题
 *
 */
public class Client10 {

    private static Client10 client10;

    private Client10() {
        System.out.println(Thread.currentThread() + "\t我是构造方法Client10");
    }


    public static Client10 getInstance() {
        if (client10 == null) {
//            synchronized (Client10.class) {
//                if (client10 == null){
                    client10 = new Client10();
//                }
//            }
        }
        return client10;
    }


    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                Client10.getInstance();
            }).start();
        }
    }

}
